<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
  <meta name="generator" content=
  "HTML Tidy for Linux/x86 (vers 1 September 2005), see www.w3.org">

  <title>memcmp</title>
  <link href="../cppreference.css" rel="stylesheet" type="text/css">
</head>

<body>
<table>
  <tr>
  <td>
  <div class="body-content">

  <div class="header-box">
    <a href="../index.html">cppreference.com</a> &gt; <a href=
    "index.html">Standard C String and Character</a> &gt; <a href=
    "memcmp.html">memcmp</a>
  </div>

  <div class="name-format">
    memcmp
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;string.h&gt;
  int memcmp( const void *buffer1, const void *buffer2, size_t count );
</pre>

  <p>The function memcmp() compares the first <em>count</em> characters
  of <em>buffer1</em> and <em>buffer2</em>. The return values are as
  follows:</p>

  <table class="code-table">
    <tr>
      <th class="code-table-th">Value</th>

      <th class="code-table-th">Explanation</th>
    </tr>

    <tr>
      <td class="code-table-td">less than 0</td>

      <td class="code-table-td">buffer1 is less than buffer2</td>
    </tr>

    <tr>
      <td class="code-table-td">equal to 0</td>

      <td class="code-table-td">buffer1 is equal to buffer2</td>
    </tr>

    <tr>
      <td class="code-table-td">greater than 0</td>

      <td class="code-table-td">buffer1 is greater than buffer2</td>
    </tr>
  </table>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    <a href="memchr.html">memchr</a><br>
    <a href="memcpy.html">memcpy</a><br>
    <a href="memset.html">memset</a><br>
    <a href="strcmp.html">strcmp</a>
  </div>
  </div>
  </td>
  


  </tr>
  </table>
</body></html>
